package com.hk;

import java.util.Arrays;

public class Pitcher {
	private int[] gong;
	public Pitcher() {
		this(3);
	}
	public Pitcher(int n) {
		gong = new int[n];
	}
	public int[] getGong() {
		return gong;
	}
	public void make(){
		Arrays.fill(gong, -1);
		int n = gong.length;
		int cnt = 0;
		while (cnt!=n) {
			int temp = this.makeNum();
			if(!this.hasSame(temp)){
				gong[cnt++] = temp;
			}
		}
	}
	private boolean hasSame(int temp) {
		for (int i = 0; i < gong.length; i++) {
			if(gong[i]==temp){
				return true;
			}
		}
		return false;
	}
	private int makeNum(){
		return (int)(Math.random()*9) + 1;
	}
	public void print(){
		int n = gong.length;
		System.out.printf("[");
		for (int i = 0; i < n-1; i++) {
			System.out.printf("%d,", gong[i]);
		}
		System.out.printf("%d]", gong[n-1]);
	}
	@Override
	public String toString() {
		String s = "[";
		int n = gong.length;
		
		for (int i = 0; i < n-1; i++) {
			s += String.format("%d,", gong[i]);
		}
		s += String.format("%d]", gong[n-1]);		
		return s;
	}
}
